import {findPurchaseInfoById,findByIdGoods} from '@/api/sales/salesPutStorageDetails'
import PutstorageInfo from "@/components/putstorageInfo";

export default {
    components: {PutstorageInfo},
    data() {
        return {
            tableData:[],
            putStotageInfo:'',
            searchParams:{currentPage:1,pageSize:10,id:this.$route.params.id},
            total:0,
            formData:{}
        };
    },
    methods:{
        async findPurchaseInfoById(){
            this.putStotageInfo =  await findPurchaseInfoById(this.$route.params.id);
        },
        selectChange(brandList){
            if (brandList.length == 1){
                this.formData.id = brandList[0].id;
            }
            this.batchIds = brandList.map(item=>item.id);
        },
        async searchPage(){
            let response = await findByIdGoods(this.searchParams);
            this.tableData = response.data;
            this.total=response.total;
        },
        currentPageChange(currentIndex){
            this.searchParams.currentPage=currentIndex;
            this.searchPage();
        },
        inputImel(obj){
            this.$store.commit('SET_PutStotageInfo', this.putStotageInfo)
            this.$store.commit('SET_Goods', obj)
            this.$router.push({
                path: `/inputImel/${this.$route.params.id}/${obj.putStorageImelId}`,
            })
        }
    },
    created(){
        this.searchPage()
        this.findPurchaseInfoById()
    }
};
